package com.gltc.framework;

import javax.sql.DataSource;

import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.ClassPathResource;

@Configuration
@MapperScan(basePackages ="com.gltc.dao",sqlSessionFactoryRef="dbhy")
public class MysqlSqlSessionConfig {

	@Autowired
	@Qualifier("mysqltc")
	private DataSource mysqltc;

	@Bean(name = "dbhy")
	public SqlSessionFactoryBean getDbhy() {
		SqlSessionFactoryBean dbhy = new SqlSessionFactoryBean();
		dbhy.setDataSource(mysqltc);
		// 开启自动驼峰命名规则映射
		dbhy.setConfigLocation(new ClassPathResource("mybatis.xml"));
		return dbhy;
	}
}
